import time

from base_driver.basedriver_util import BaseDriverUtil


class HomePage(BaseDriverUtil):
    """
        百度搜索首页
    """
    search_input_path = ("id", "kw")
    search_button_path = ("id", "su")
    login_button_path = ("xpath", "//a[text()='登录']")

    def search(self, keyword):
        """
        搜索
        :param keyword: 搜索关键字
        :return:
        """
        self.my_input(self.search_input_path, keyword)
        self.my_click(self.search_button_path)
        self.my_screenshot("search.png")

    def goto_login_page(self):
        self.my_click(self.login_button_path)
        self.my_screenshot("go_to_login.png")
        from base_driver.loginpage import LoginPage
        return LoginPage(self.driver)